package cn.shrek.service;

import cn.shrek.bean.Student;
import cn.shrek.bean.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * value 正常情况下，去哪里调用方法 这里写provider的名字
 * fallback 当provider发生了故障的时候，无法访问了，那么我们改调用谁？
 */
@Component
@FeignClient(value = "provider",fallback = ConsumerServiceImplFallBack.class)
public interface ConsumerService {
    /**
     * 查询所有
     * @return
     */
    @RequestMapping(value = "/findAll")
    List<User> findAll();

    @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
    String doLogin(@RequestParam("user_name")String user_name,  @RequestParam("userpwd")String userpwd);
  @RequestMapping(value = "/end")
    String go_index();
    /**
     * 通过id查询所有
     * @return
     */
    @RequestMapping(value = "/findById",method = RequestMethod.POST)
    List<Student> findById(@RequestParam("s_id") Integer s_id);

    /**
     * 增加一条数据
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    void add(@RequestBody Student Student);

    /**
     * 更新一条数据
     */
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    void update(@RequestBody Student Student);
    /**
     * 删除一条数据
     */
    @RequestMapping(value="/delete",method = RequestMethod.POST)
    int delete(@RequestParam("s_id") int s_id);

}
